class SelfDestructThingy extends Actor;

var int Damage;
var float DamageRadius;
var int MomentumTransfer;
var class<DamageType> MyDamageType;

// camera shakes //
var() vector ShakeRotMag;           // how far to rot view
var() vector ShakeRotRate;          // how fast to rot view
var() float  ShakeRotTime;          // how much time to rot the instigator's view
var() vector ShakeOffsetMag;        // max view offset vertically
var() vector ShakeOffsetRate;       // how fast to offset view vertically
var() float  ShakeOffsetTime;       // how much time to offset view

auto state Dying
{
	function BeginState()
	{
		ShakeView();
	}

	function ShakeView()
	{
		local Controller C;
		local PlayerController PC;
		local float Dist, Scale;

		for(C = Level.ControllerList; C != None; C = C.NextController)
		{
			PC = PlayerController(C);

			if(PC != None && PC.ViewTarget != None)
			{
				Dist = VSize(Location - PC.ViewTarget.Location);

				if(Dist < DamageRadius * 2.0)
				{
					if (Dist < DamageRadius)
						Scale = 1.0;
					else
						Scale = (DamageRadius * 2.0 - Dist) / DamageRadius;

					C.ShakeView(ShakeRotMag * Scale, ShakeRotRate, ShakeRotTime, ShakeOffsetMag * Scale, ShakeOffsetRate, ShakeOffsetTime);
				}
			}
		}
	}

Begin:
	Spawn(class'SelfDestructEmitter',,,, Rot(0, 16384, 0));
	MakeNoise(1.0);
	HurtRadius(Damage, DamageRadius*0.125, MyDamageType, MomentumTransfer, Location);
	Sleep(0.5);
	HurtRadius(Damage, DamageRadius*0.300, MyDamageType, MomentumTransfer, Location);
	Sleep(0.2);
	HurtRadius(Damage, DamageRadius*0.475, MyDamageType, MomentumTransfer, Location);
	Sleep(0.2);
	HurtRadius(Damage, DamageRadius*0.650, MyDamageType, MomentumTransfer, Location);
	Sleep(0.2);
	HurtRadius(Damage, DamageRadius*0.825, MyDamageType, MomentumTransfer, Location);
	Sleep(0.2);
	HurtRadius(Damage, DamageRadius*1.000, MyDamageType, MomentumTransfer, Location);
	Destroy();
}

defaultproperties
{
     Damage=250
     DamageRadius=2000.000000
     MomentumTransfer=200000
     MyDamageType=Class'taskforces.DamTypeSentinelExplosion'
     ShakeRotMag=(Z=250.000000)
     ShakeRotRate=(Z=2500.000000)
     ShakeRotTime=6.000000
     ShakeOffsetMag=(Z=10.000000)
     ShakeOffsetRate=(Z=200.000000)
     ShakeOffsetTime=10.000000
     DrawType=DT_None
     RemoteRole=ROLE_None
     LifeSpan=5.000000
}
